import { createRouter, createWebHistory } from 'vue-router'
import userRoutes from './modules/user.js'
import musicRoutes from './modules/music.js'

const routes = [
  {
    path: '/random',
    name: 'random',
    component: () => import('@/views/random/RandomPage.vue')
  },
  ...musicRoutes,
  ...userRoutes
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

router.beforeEach(async (to) => {
  // 在导航之前设置页面标题
  document.title = to.meta.title || 'jie-music'

})

export default router
